/*
 *
 * Copyright (c) 2010-2012  CNZCOM Company
 * 深圳市闪电通讯技术有限公司  版权所有
 *  2010-2012
 *
 *
 *
 */

package com.android.launcher3;

import java.io.IOException;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import android.content.ContentValues;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;

import com.android.internal.util.XmlUtils;

final class LauncherConfig {
	private static final String LOG_TAG = "Launcher.LauncherConfig";
	private static final String TAG_COLUMN = "columnno";
	private static final String TAG_CONFIG = "config";
	private static final String TAG_ITEMNO = "itemno";
	private static final String TAG_LAUNCHER = "launcher";
	private static final String TAG_PAGEINDICATOR = "pageindicator";
	private static final String TAG_PRODUCT = "product";

	public static boolean getUse16BitWindow(final Context paramContext) {
		boolean bool1 = false;

		try {
			XmlResourceParser localXmlResourceParser = paramContext
					.getResources().getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int i = localXmlResourceParser.getDepth();

			while (true) {
				int j = localXmlResourceParser.next();

				if (((j == 3) && (localXmlResourceParser.getDepth() <= i))
						|| (j == 1)) {
					break;
				}

				if (j != 2) {
					continue;
				}

				String str = localXmlResourceParser.getName();
				int[] arrayOfInt = R.styleable.Launcher;
				TypedArray localTypedArray = paramContext
						.obtainStyledAttributes(localAttributeSet, arrayOfInt);

				if (!TAG_LAUNCHER.equals(str)) {
					continue;
				}

				return localTypedArray.getBoolean(
						R.styleable.Launcher_use16BitWindow, bool1);
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);

			return bool1;
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);

			return bool1;
		}

		return bool1;
	}

	public static boolean getUseMainMenuConcentrationEffect(
			final Context paramContext) {
		boolean bool1 = false;

		try {
			XmlResourceParser localXmlResourceParser = paramContext
					.getResources().getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int i = localXmlResourceParser.getDepth();

			while (true) {
				int j = localXmlResourceParser.next();

				if (((j == 3) && (localXmlResourceParser.getDepth() <= i))
						|| (j == 1)) {
					break;
				}

				if (j != 2) {
					continue;
				}

				String str = localXmlResourceParser.getName();
				int[] arrayOfInt = R.styleable.Launcher;

				if (!TAG_LAUNCHER.equals(str)) {
					continue;
				}

				TypedArray localTypedArray = paramContext
						.obtainStyledAttributes(localAttributeSet, arrayOfInt);

				return localTypedArray.getBoolean(
						R.styleable.Launcher_useMainMenuConcentrationEffect,
						bool1);
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);

			return bool1;
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);

			return bool1;
		}

		return bool1;
	}

	public static boolean landscapeScreen_isUseFullScreenQuickView(
			final Context paramContext) {
		ContentValues localContentValues = new ContentValues();
		boolean bool1 = false;

		try {
			XmlResourceParser localXmlResourceParser = paramContext
					.getResources().getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int i = localXmlResourceParser.getDepth();

			while (true) {
				int j = localXmlResourceParser.next();

				if (((j == 3) && (localXmlResourceParser.getDepth() <= i))
						|| (j == 1)) {
					break;
				}

				if (j != 2) {
					continue;
				}

				String str = localXmlResourceParser.getName();
				int[] arrayOfInt = R.styleable.Launcher;
				TypedArray localTypedArray = paramContext
						.obtainStyledAttributes(localAttributeSet, arrayOfInt);
				localContentValues.clear();

				if (!TAG_LAUNCHER.equals(str)) {
					continue;
				}

				boolean bool2 = localTypedArray.getBoolean(3, bool1);
				bool1 = bool2;
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);

			return bool1;
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);
		}

		return bool1;
	}

	public static boolean pageIndicator_getUseLargeDrawablesOnly(
			final Context paramContext) {
		boolean bool1 = false;

		try {
			XmlResourceParser localXmlResourceParser = paramContext
					.getResources().getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int i = localXmlResourceParser.getDepth();

			while (true) {
				int j = localXmlResourceParser.next();

				if (((j == 3) && (localXmlResourceParser.getDepth() <= i))
						|| (j == 1)) {
					break;
				}

				if (j != 2) {
					continue;
				}

				String str = localXmlResourceParser.getName();

				if (!TAG_PAGEINDICATOR.equals(str)) {
					continue;
				}

				int[] arrayOfInt = R.styleable.Launcher;
				TypedArray localTypedArray = paramContext
						.obtainStyledAttributes(localAttributeSet, arrayOfInt);

				return localTypedArray.getBoolean(
						R.styleable.Launcher_useLargeDrawablesOnly, bool1);
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);
			localXmlPullParserException.printStackTrace();

			return bool1;
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);
			localIOException.printStackTrace();
		}

		return bool1;
	}

	static int getColumnNo(final Context paramContext) {
		int i = 4;

		try {
			XmlResourceParser localXmlResourceParser = paramContext
					.getResources().getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int j = localXmlResourceParser.getDepth();

			while (true) {
				int k = localXmlResourceParser.next();

				if (((k == XmlPullParser.END_TAG) && (localXmlResourceParser
						.getDepth() <= j)) || (k == XmlPullParser.END_DOCUMENT)) {
					break;
				}

				if (k != XmlPullParser.START_TAG) {
					continue;
				}

				String str = localXmlResourceParser.getName();

				if (!TAG_COLUMN.equals(str)) {
					continue;
				}

				int[] arrayOfInt = R.styleable.MenuManager;
				TypedArray localTypedArray = paramContext
						.obtainStyledAttributes(localAttributeSet, arrayOfInt);

				return localTypedArray.getInt(
						R.styleable.MenuManager_menuColumnCount, 4);
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);

			return i;
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);

			return i;
		}

		return i;
	}

	static int getDefaultScreenCount(final Context paramContext) {
		int i = 7;

		try {
			XmlResourceParser localXmlResourceParser = paramContext
					.getResources().getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int j = localXmlResourceParser.getDepth();

			while (true) {
				int k = localXmlResourceParser.next();

				if (((k == 3) && (localXmlResourceParser.getDepth() <= j))
						|| (k == 1)) {
					break;
				}

				if (k != 2) {
					continue;
				}

				String str = localXmlResourceParser.getName();

				if (!TAG_LAUNCHER.equals(str)) {
					continue;
				}

				int[] arrayOfInt = R.styleable.Launcher;
				TypedArray localTypedArray = paramContext
						.obtainStyledAttributes(localAttributeSet, arrayOfInt);

				return localTypedArray.getInt(
						R.styleable.Launcher_defaultScreenCount, i);
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);
		}

		return i;
	}

	// static int getItemNoOfPage(final Context paramContext) {
	// int i = 16;
	//
	// try {
	// XmlResourceParser localXmlResourceParser = paramContext.getResources()
	// .getXml(R.xml.launcher_config);
	// AttributeSet localAttributeSet =
	// Xml.asAttributeSet(localXmlResourceParser);
	// XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);
	//
	// int j = localXmlResourceParser.getDepth();
	//
	// while (true) {
	// int k = localXmlResourceParser.next();
	//
	// if (((k == 3) && (localXmlResourceParser.getDepth() <= j))
	// || (k == 1)) {
	// break;
	// }
	//
	// if (k != 2) {
	// continue;
	// }
	//
	// String str = localXmlResourceParser.getName();
	//
	// if (!TAG_ITEMNO.equals(str)) {
	// continue;
	// }
	//
	// int[] arrayOfInt = R.styleable.MenuManager;
	// TypedArray localTypedArray =
	// paramContext.obtainStyledAttributes(localAttributeSet,
	// arrayOfInt);
	//
	// return localTypedArray.getInt(R.styleable.MenuManager_itemNumOfPage,
	// 16);
	// }
	// } catch (final XmlPullParserException localXmlPullParserException) {
	// Log.w(LOG_TAG, "Got exception parsing config.",
	// localXmlPullParserException);
	// } catch (final IOException localIOException) {
	// Log.w(LOG_TAG, "Got exception parsing config.", localIOException);
	// }
	//
	// return i;
	// }

	static String getProductModel(final Context paramContext) {
		String localObject1 = null;

		try {
			XmlResourceParser localXmlResourceParser = paramContext
					.getResources().getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int i = localXmlResourceParser.getDepth();

			while (true) {
				int j = localXmlResourceParser.next();

				if (((j == 3) && (localXmlResourceParser.getDepth() <= i))
						|| (j == 1)) {
					break;
				}

				if (j != 2) {
					continue;
				}

				String str1 = localXmlResourceParser.getName();

				if (!TAG_PRODUCT.equals(str1)) {
					continue;
				}

				int[] arrayOfInt = R.styleable.Product;
				TypedArray localTypedArray = paramContext
						.obtainStyledAttributes(localAttributeSet, arrayOfInt);

				return localTypedArray.getString(R.styleable.Product_model);
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);
		}

		return localObject1;
	}

	static String getProductModelFamily(final Context paramContext) {
		ContentValues localContentValues = new ContentValues();
		String localObject1 = null;

		try {
			XmlResourceParser localXmlResourceParser = paramContext
					.getResources().getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int i = localXmlResourceParser.getDepth();

			while (true) {
				int j = localXmlResourceParser.next();

				if (((j == 3) && (localXmlResourceParser.getDepth() <= i))
						|| (j == 1)) {
					break;
				}

				if (j != 2) {
					continue;
				}

				String str1 = localXmlResourceParser.getName();

				if (!TAG_PRODUCT.equals(str1)) {
					continue;
				}

				int[] arrayOfInt = R.styleable.Launcher;
				TypedArray localTypedArray = paramContext
						.obtainStyledAttributes(localAttributeSet, arrayOfInt);
				localContentValues.clear();

				return localTypedArray
						.getString(R.styleable.Launcher_modelFamily);
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);
		}

		return localObject1;
	}

	static int getScreenCount(final Context context) {
		ContentValues localContentValues = new ContentValues();
		int i = 7;

		try {
			XmlResourceParser localXmlResourceParser = context.getResources()
					.getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int j = localXmlResourceParser.getDepth();

			while (true) {
				int k = localXmlResourceParser.next();

				if (((k == 3) && (localXmlResourceParser.getDepth() <= j))
						|| (k == 1)) {
					break;
				}

				if (k != 2) {
					continue;
				}

				String str = localXmlResourceParser.getName();

				if (!TAG_LAUNCHER.equals(str)) {
					continue;
				}

				int[] arrayOfInt = R.styleable.Launcher;
				TypedArray localTypedArray = context.obtainStyledAttributes(
						localAttributeSet, arrayOfInt);
				localContentValues.clear();

				return localTypedArray.getInt(R.styleable.Launcher_screenCount,
						i);
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);
		}

		return i;
	}

	static boolean getUseMainMenuListMode(final Context paramContext) {
		boolean bool1 = false;

		try {
			XmlResourceParser localXmlResourceParser = paramContext
					.getResources().getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int i = localXmlResourceParser.getDepth();

			while (true) {
				int j = localXmlResourceParser.next();

				if (((j == 3) && (localXmlResourceParser.getDepth() <= i))
						|| (j == 1)) {
					break;
				}

				if (j != 2) {
					continue;
				}

				String str = localXmlResourceParser.getName();

				if (!TAG_LAUNCHER.equals(str)) {
					continue;
				}

				int[] arrayOfInt = R.styleable.Launcher;
				TypedArray localTypedArray = paramContext
						.obtainStyledAttributes(localAttributeSet, arrayOfInt);

				return localTypedArray.getBoolean(
						R.styleable.Launcher_useMainMenuListMode, bool1);
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);

			return bool1;
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);

			return bool1;
		}

		return bool1;
	}

	static int getWorkspaceCellsX(final Context paramContext) {
		int i = 4;

		try {
			XmlResourceParser localXmlResourceParser = paramContext
					.getResources().getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int j = localXmlResourceParser.getDepth();

			while (true) {
				int k = localXmlResourceParser.next();

				if (((k == 3) && (localXmlResourceParser.getDepth() <= j))
						|| (k == 1)) {
					break;
				}

				if (k != 2) {
					continue;
				}

				String str = localXmlResourceParser.getName();
				int[] arrayOfInt = R.styleable.Launcher;
				TypedArray localTypedArray = paramContext
						.obtainStyledAttributes(localAttributeSet, arrayOfInt);

				if (!TAG_LAUNCHER.equals(str)) {
					continue;
				}

				return localTypedArray.getInteger(
						R.styleable.Launcher_workspaceCellsX, i);
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);
		}

		return i;
	}

	static int getWorkspaceCellsY(final Context paramContext) {
		ContentValues localContentValues = new ContentValues();
		int i = 4;

		try {
			XmlResourceParser localXmlResourceParser = paramContext
					.getResources().getXml(R.xml.launcher_config);
			AttributeSet localAttributeSet = Xml
					.asAttributeSet(localXmlResourceParser);
			XmlUtils.beginDocument(localXmlResourceParser, TAG_CONFIG);

			int j = localXmlResourceParser.getDepth();

			while (true) {
				int k = localXmlResourceParser.next();

				if (((k == 3) && (localXmlResourceParser.getDepth() <= j))
						|| (k == 1)) {
					break;
				}

				if (k != 2) {
					continue;
				}

				String str = localXmlResourceParser.getName();

				if (!TAG_LAUNCHER.equals(str)) {
					continue;
				}

				int[] arrayOfInt = R.styleable.Launcher;
				TypedArray localTypedArray = paramContext
						.obtainStyledAttributes(localAttributeSet, arrayOfInt);
				localContentValues.clear();

				return localTypedArray.getInteger(
						R.styleable.Launcher_workspaceCellsY, i);
			}
		} catch (final XmlPullParserException localXmlPullParserException) {
			Log.w(LOG_TAG, "Got exception parsing config.",
					localXmlPullParserException);

			return i;
		} catch (final IOException localIOException) {
			Log.w(LOG_TAG, "Got exception parsing config.", localIOException);
		}

		return i;
	}
}
